package tests;

import common.Utils;
import org.openqa.selenium.By;

import java.time.Duration;
import java.util.Set;

public class ProjectPage extends Utils {
    public static String url = detailUrl;
    public ProjectPage() {
        super(url);
    }
    //点击项目详情页并且检查
    public void checkProjectDetail() throws InterruptedException {
        //手动点击切换url
        driver.get("http://49.235.61.184:8080/project");
        //检查我都项目中的元素是否可见
        //检查我的项目标题是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > div > span"));
        //检查搜索框和排序种类是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div > div"));
        //检查新建按钮是否可见
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > span > div > div > button"));
        //检查分页栏是否存在
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.pagination-container > ul"));
        //点击新建按钮是否正常出现下拉框
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > span > div > div > button")).click();
        Thread.sleep(1000);
        //检查是否出现下拉框
        driver.findElements(By.cssSelector("body > div:nth-child(7) > div > div"));
        System.out.println("下拉框显示正常");

        //点击下拉框中的问卷调查
        driver.findElement(By.cssSelector("body > div:nth-child(7) > div > div > ul > li:nth-child(1) > span")).click();
        Thread.sleep(1000);
        //检查问卷调查页面是否正常显示
        driver.findElement(By.cssSelector("#editorContent"));
        System.out.println("问卷调查页面显示正常");

        //回退到我的项目页面
        driver.navigate().back();
        Thread.sleep(1000);
        //重新点击新建按钮是否正常跳转到在线考试页面
        //点击新建按钮是否正常出现下拉框
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > span > div > div > button")).click();

        //检查是否出现下拉框
        driver.findElements(By.cssSelector("body > div:nth-child(7) > div > div"));
        System.out.println("下拉框显示正常");

        //点击下拉框中的在线考试
        driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div > ul > li:nth-child(2) > span")).click();

        //检查在线考试页面是否正常显示
        driver.findElement(By.cssSelector("#editorContent"));
        System.out.println("在线考试页面显示正常");
        //回退到我的项目页面
        driver.navigate().back();

        //重新点击新建按钮是否正常跳转到在线考试页面
        //点击新建按钮是否正常出现下拉框
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > span > div > div > button")).click();
        Thread.sleep(1000);
        //检查是否出现下拉框
        driver.findElements(By.cssSelector("body > div:nth-child(7) > div > div"));
        System.out.println("下拉框显示正常");
        //点击下拉框中的通过excel导入(快查)
        driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div > ul > li:nth-child(3) > span")).click();
        Thread.sleep(1000);
        //检查通过excel导入(快查)页面是否正常显示
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body"));
        System.out.println("通过excel导入(快查)页面显示正常");
        //点击取消按钮
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-footer > button.ant-btn.ant-btn-default")).click();



        //重新点击新建按钮是否正常跳转到在线考试页面
        //点击新建按钮是否正常出现下拉框
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > span > div > div > button")).click();
        Thread.sleep(1000);
        //检查是否出现下拉框
        driver.findElements(By.cssSelector("body > div:nth-child(7) > div > div"));
        System.out.println("下拉框显示正常");
        //点击下拉框中的通过文本导入
        driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div > ul > li:nth-child(4) > span")).click();
        Thread.sleep(1000);
        //检查通过文本导入页面是否正常显示
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-drawer-content-wrapper > div > div > div.ant-drawer-body > div.text-body"));
        System.out.println("通过文本导入页面显示正常");
        //点击关闭按钮
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-drawer-content-wrapper > div > div > div.ant-drawer-header > div.ant-drawer-extra > div > div:nth-child(1) > button")).click();
        Thread.sleep(1000);


        //重新点击新建按钮是否正常跳转到在线考试页面
        //点击新建按钮是否正常出现下拉框
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > span > div > div > button")).click();
        Thread.sleep(1000);
        //检查是否出现下拉框
        driver.findElements(By.cssSelector("body > div:nth-child(7) > div > div"));
        System.out.println("下拉框显示正常");
        //点击下拉框中的模板导入
        driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div > ul > li:nth-child(5) > span")).click();
        Thread.sleep(1000);
        //检查模板导入页面是否正常显示
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body"));
        System.out.println("模板导入页面显示正常");
        //点击取消按钮
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-footer > button.ant-btn.ant-btn-default")).click();
        Thread.sleep(1000);


        //重新点击新建按钮是否正常跳转到在线考试页面
        //点击新建按钮是否正常出现下拉框
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > span > div > div > button")).click();
        Thread.sleep(1000);
        //检查是否出现下拉框
        driver.findElements(By.cssSelector("body > div:nth-child(7) > div > div"));
        System.out.println("下拉框显示正常");
        //点击下拉框中的新建文件夹
        driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div > ul > li:nth-child(6) > span")).click();
        Thread.sleep(1000);
        //检查新建文件夹页面是否正常显示
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body"));
        System.out.println("新建文件夹页面显示正常");
        //点击取消按钮
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-footer > button.ant-btn.ant-btn-default")).click();
        Thread.sleep(1000);

        //重新点击新建按钮是否正常跳转到在线考试页面
        //点击新建按钮是否正常出现下拉框
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > span > div > div > button")).click();
        Thread.sleep(1000);
        //检查是否出现下拉框
        driver.findElements(By.cssSelector("body > div:nth-child(7) > div > div"));
        System.out.println("下拉框显示正常");
        //点击下拉框中的回收站
        driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div > ul > li:nth-child(7) > span")).click();
        Thread.sleep(1000);
        //检查回收站页面是否正常显示
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > div > div > div > div"));
        System.out.println("回收站页面显示正常");
        //点击取消按钮
        driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > button")).click();
        //回到我的项目页面
        System.out.println("回到我的项目页面");
        Thread.sleep(1000);

        //保存url
        detailUrl=driver.getCurrentUrl();
    }
}
